package edu.hebeu.evil.freshmenguide;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.github.ksoichiro.android.observablescrollview.ObservableListView;
import com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks;
import com.github.ksoichiro.android.observablescrollview.ScrollState;

import java.util.ArrayList;
import java.util.List;

import edu.hebeu.evil.freshmenguide.Utils.Adapter.CommonAdapter;
import edu.hebeu.evil.freshmenguide.Utils.Adapter.ViewHolder;

/********************************************
 * 工程名：FreshmenGuide
 * 包名：edu.hebeu.evil.freshmenguide
 * 时间：16-7-4 下午11:25
 * 作者：白雨濃 evil
 * 邮箱：evilbai@foxmail.com
 * 内容：
 ********************************************/
public class Test extends AppCompatActivity implements ObservableScrollViewCallbacks
{
    private ObservableListView listView;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.test);
        initView();

        listView.setScrollViewCallbacks(this);


        ArrayList<String> items = new ArrayList<String>();
        for (int i = 1; i <= 100; i++)
        {
            items.add("Item " + i);
        }

        listView.setAdapter(new ArrayAdapter<String>(
                this, android.R.layout.simple_list_item_1, items));

    }

    private void initView()
    {
        listView = (ObservableListView) findViewById(R.id.list);
    }


    @Override
    public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging)
    {

    }

    @Override
    public void onDownMotionEvent()
    {

    }

    @Override
    public void onUpOrCancelMotionEvent(ScrollState scrollState)
    {
        ActionBar ab = getSupportActionBar();
        if (scrollState == ScrollState.UP)
        {
            if (ab.isShowing())
            {
                ab.hide();
            }
        }
        else if (scrollState == ScrollState.DOWN)
        {
            if (!ab.isShowing())
            {
                ab.show();
            }
        }
    }

}
